package com.zzh.utils;

import com.zzh.interfaces.IErrorCodeEnum;
import lombok.Getter;

/**
 * 
 * Copyright: Copyright (c) 2020 mosc
 * @ClassName: BaseException.java
 * @Description [业务异常基础接口]
 * @version: v1.0.0
 * @author mosc
 * @CreateDate 2020年6月11日 下午4:38:41 
 * @update [序号][日期YYYY-MM-DD] [更改人姓名][变更描述]
 */
@Getter
public class BaseException extends RuntimeException{
	
	
	/**
	 * @Fields serialVersionUID : TODO
	 */
	private static final long serialVersionUID = 3L;

	/**
	 * 业务异常消息对象
	 */
	private IErrorCodeEnum errorCodeEnum;
	
	/**
	 * 业务异常消息参数
	 */
	private Object args;
	
	public BaseException(IErrorCodeEnum errorCodeEnum) {
        super(errorCodeEnum.getMsg());
        this.errorCodeEnum = errorCodeEnum;
    }

    public BaseException(String code, String msg) {
        super(msg);
        this.errorCodeEnum = new IErrorCodeEnum() {
            @Override
            public String getCode() {
                return code;
            }

            @Override
            public String getMsg() {
                return msg;
            }
        };
    }

    public BaseException(IErrorCodeEnum errorCodeEnum, Object[] args, String message) {
        super(message);
        this.errorCodeEnum = errorCodeEnum;
        this.args = args;
    }
}
